Test Series - java script

Test Number 15/92

Q: The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for ___________
A. declaring and loading modules
B. declaring functions
C. declaring modules
D. loading modules
Solution: Both the Dojo toolkit and Google’s Closure library define provide() and require() functions for declaring and loading modules.
Q: The maximum number of global symbols a module can define is ____________
A. 2
B. 3
C. 1
D. 7
Solution: Generally, the various modules are allowed to run in the pristine (or near pristine) environment that it expects. The modules should minimize the number of global symbols they define – ideally, no module should define more than one.
Q: To define each of the set classes as a property of the sets object (namespace) for the module, the statement is
A. sets = sets.AbstractEnumerableSet.extend();
B. sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);
C. sets.SingletonSet = sets.extend(…);
D. sets = sets.extend(…);
Solution: Singleton is an object which can only be instantiated once. The extend keyword is used in class declarations or class expressions to create a class which is a child of another class. The sets object is the namespace for the module, and we define each of the set classes as a property of this object.
Q: The scope of a function is also called as ________
A. Predefined function
B. Module function
C. Public function
D. Private function
Solution: The scope of a function can be used as a private namespace for a module. Therefore, the scope of a function is called a module function.
Q: Modules that have more than one item in their API can ________
A. Assign itself to a global variable
B. Invoke another module of the same kind
C. Return a namespace object
D. Invoke another module of the same kind
Solution: Namespace is a container for a set of identifiers, functions, methods and all that. It gives a level of direction to its contents so that it will be well distinguished and organized. Modules that have more than one item in their API can return a namespace object.
Q: The provides() function and the exportsobject are used to _________
A. Register the module’s API and Store their API
B. Call the modules api
C. Store the module’s API
D. Register the modules api
Solution: Frameworks that define module loading systems may have other methods of exporting a module’s API. There may be a provides() function for modules to register their API, or an exports object into which modules must store their API.
Q: The properties() method is a ________
A. Enumerable method
B. Non-enumerable method
C. Operational method
D. calling method
Solution: The properties() is a method to get information of the properties of a particular object. properties() method is a non-enumerable method.
Q: What can be done in order to avoid the creation of global variables in JavaScript?
A. To use a method that defines all the variables
B. To use an object that has the reference to all the variables
C. To use an object as its namespace
D. To use global functions
Solution: One way for a module to avoid the creation of global variables is to use an object as its namespace. Instead of defining global functions and variables, it stores the functions and values as properties of an object (which may be referenced to a global variable).
Q: What will be the output of the following JavaScript code?

A. true
B. False
C. error
D. undefined
Solution: isInteger method returns true if the value is of the type Number, and an integer (a number without decimals). Otherwise it returns false.

You Have Score    /9